package android.Dominion.GameBLL.Cards;

import java.util.ArrayList;
import java.util.List;


public class CardFactory
{
	private static int currentCardId = 0;

	public CardFactory()
	{
	}

	public List<CardPile> GetTreasureCards(int gameType)
	{
		List<CardPile> treasures = new ArrayList<CardPile>();

		if (gameType == 1)
		{
			final int GOLD_COUNT = 30;
			final int SILVER_COUNT = 40;
			final int COPPER_COUNT = 60;

			CardPile goldPile = new CardPile();
			CardPile silverPile = new CardPile();
			CardPile copperPile = new CardPile();

			for (int i = 0; i < GOLD_COUNT; i++)
			{
				goldPile.add(MakeCard("GOLD"));
			}
			for (int i = 0; i < SILVER_COUNT; i++)
			{
				silverPile.add(MakeCard("SILVER"));
			}
			for (int i = 0; i < COPPER_COUNT; i++)
			{
				copperPile.add(MakeCard("COPPER"));
			}

		}

		return treasures;
	}
	public List<CardPile> GetVictoryCards(int gameType)
	{
		List<CardPile> victory = new ArrayList<CardPile>();

		if (gameType == 1)
		{
			final int ESTATE_COUNT = 8;
			final int DUCHY_COUNT = 8;
			final int PROVINCE_COUNT = 8;

			CardPile estatePile = new CardPile();
			CardPile duchyPile = new CardPile();
			CardPile provincePile = new CardPile();

			for (int i = 0; i < ESTATE_COUNT; i++)
			{
				estatePile.add(MakeCard("ESTATE"));
			}
			for (int i = 0; i < DUCHY_COUNT; i++)
			{
				duchyPile.add(MakeCard("DUCHY"));
			}
			for (int i = 0; i < PROVINCE_COUNT; i++)
			{
				provincePile.add(MakeCard("PROVINCE"));
			}

		}

		return victory;
	}
	

	private int GetCardId()
	{
		int id = currentCardId;
		currentCardId++;
		return id;
	}

	private Card MakeCard(String cardName)
	{
		Card tempCard = null;

		if (cardName.toUpperCase() == "GOLD")
		{
			tempCard = new Card();
			tempCard.setCardId(GetCardId());
			tempCard.setType(CardType.Treasure);
			tempCard.setOwner(null);
			tempCard.setCost(6);
			tempCard.setMoneyValue(3);
			tempCard.setName("Gold");
		} else if (cardName.toUpperCase() == "SILVER")
		{
			tempCard = new Card();
			tempCard.setCardId(GetCardId());
			tempCard.setType(CardType.Treasure);
			tempCard.setOwner(null);
			tempCard.setCost(3);
			tempCard.setMoneyValue(2);
			tempCard.setName("Silver");
		} else if (cardName.toUpperCase() == "COPPER")
		{
			tempCard = new Card();
			tempCard.setCardId(GetCardId());
			tempCard.setType(CardType.Treasure);
			tempCard.setOwner(null);
			tempCard.setCost(0);
			tempCard.setMoneyValue(1);
			tempCard.setName("Copper");
		}else if(cardName.toUpperCase() == "ESTATE"){
			tempCard = new Card();
			tempCard.setCardId(GetCardId());
			tempCard.setType(CardType.Victory);
			tempCard.setOwner(null);
			tempCard.setCost(2);
			tempCard.setName("Estate");
		}else if(cardName.toUpperCase() == "DUCHY"){
			tempCard = new Card();
			tempCard.setCardId(GetCardId());
			tempCard.setType(CardType.Victory);
			tempCard.setOwner(null);
			tempCard.setCost(5);
			tempCard.setName("Duchy");
		}else if(cardName.toUpperCase() == "PROVINCE"){
			tempCard = new Card();
			tempCard.setCardId(GetCardId());
			tempCard.setType(CardType.Victory);
			tempCard.setOwner(null);
			tempCard.setCost(8);
			tempCard.setName("Province");
		}

		return tempCard;
	}
}
